<template>
  <el-drawer v-model="drawerVisible" :destroy-on-close="true" size="450px" :title="`${drawerProps.title}`">
    <el-space direction="vertical">
      <el-descriptions :column="1" title="调拨单信息" border>
        <el-descriptions-item width="300" label="订单序号">{{ drawerProps.row.orderId }}</el-descriptions-item>
        <el-descriptions-item width="300" label="任务序号">{{ drawerProps.row.taskId }}</el-descriptions-item>
        <el-descriptions-item width="300" label="调拨单状态">
          <el-tag v-if="drawerProps.row?.transferStatus === 0" type="warning">待调度</el-tag>
          <el-tag v-if="drawerProps.row?.transferStatus === 1" type="success">已调度</el-tag>
          <el-tag v-if="drawerProps.row?.transferStatus === 2" type="danger">挂起</el-tag>
        </el-descriptions-item>
        <el-descriptions-item width="300" label="出库库号">{{ drawerProps.row.outboundWarehouseId }}</el-descriptions-item>
        <el-descriptions-item width="300" label="入库库号">{{ drawerProps.row.inboundWarehouseId }}</el-descriptions-item>
        <el-descriptions-item width="300" label="创建时间">{{ drawerProps.row?.createTime }}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions :column="1" title="订单项信息" border>
        <el-descriptions-item width="300" label="商品名称">{{ drawerProps.row.orderItems?.[0]?.goodsName }}</el-descriptions-item>
        <el-descriptions-item width="300" label="商品价格">{{
          drawerProps.row.orderItems?.[0]?.goodsPrice
        }}</el-descriptions-item>
        <el-descriptions-item width="300" label="商品数量">{{ drawerProps.row.orderItems?.[0]?.count }}</el-descriptions-item>
        <el-descriptions-item width="300" label="计量单位">{{
          drawerProps.row.orderItems?.[0]?.measureUnit
        }}</el-descriptions-item>
      </el-descriptions>
    </el-space>
    <template #footer>
      <el-button @click="drawerVisible = false">取消</el-button>
    </template>
  </el-drawer>
</template>

<script setup lang="ts" name="DetailDrawer">
import { ref } from "vue";
import { TransferOrder } from "@/api/interface";

interface DrawerProps {
  title: string;
  isView: boolean;
  row: Partial<TransferOrder.ResTransferOrderList>;
  api?: (params: any) => Promise<any>;
  getTableList?: () => void;
}

const drawerVisible = ref(false);
const drawerProps = ref<DrawerProps>({
  isView: false,
  title: "",
  row: {}
});

// 接收父组件传过来的参数
const acceptParams = (params: DrawerProps) => {
  drawerProps.value = params;
  drawerVisible.value = true;
};

defineExpose({
  acceptParams
});
</script>
